package com.huli.controller;

import com.huli.domain.Patient;
import com.huli.service.PatientService;
import com.huli.util.Result;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/patient")
public class PatientController {
    @Autowired
    private PatientService patientService;
    //查询患者列表
    @RequestMapping("findAll")
    public List<Patient> findAll(){
        return patientService.findAll();
    }
    //患者信息删除功能
    @RequestMapping("deleteById")
    public Integer deleteById(Integer id){
        Integer integer = patientService.deleteById(id);
        return integer;
    }
//    患者信息修改功能
    @RequestMapping("updateById")
    public String updateById(@Param("id") Integer id,@Param("phone") String phone){
        String updateById = patientService.updateId(id,phone);
        return updateById;
    }
    //患者信息添加功能
    @RequestMapping("save")
    public String save(@RequestBody Patient patient){
        System.err.println(patient);
        String addindex=patientService.add(patient);
//        boolean save = patientService.save(patient);
        return addindex;
    }
    //根据ID查询所有
    @RequestMapping("selectById")
    public Patient selectById(Integer id){
        return patientService.selectById(id);
    }

}
